<template>
	<view class="container">
		<!-- 头部导航 -->
		<page-navbar :title="hotelDetail.name" backgroundColor="#87CEEB00"></page-navbar>

		<!-- 主要内容区域 -->
		<scroll-view class="content" scroll-y="true" :show-scrollbar="false">
			<!-- 酒店大图 -->
			<view class="image-section">
				<image class="main-image" :src="common.defaultImg(hotelDetail.coverId)" mode="aspectFill"></image>
				<view class="image-overlay">
					<view class="hotel-info">
						<view class="hotel-name">{{ hotelDetail.name }}</view>
						<view class="hotel-subtitle">{{ hotelDetail.position?.name }}</view>
					</view>
					<view class="hotel-btn">
						<button class="navigate-btn" @click="navigateToLocation">导航</button>
					</view>
				</view>
			</view>

			<!-- 酒店介绍 -->
			<view class="section">
				<view class="section-header">
					<svg-icon name="info" size="32" />
					<text class="section-title">酒店介绍</text>
				</view>
				<view class="description-card">
					<text class="description-text">{{ hotelDetail.introTitle }}</text>
				</view>
			</view>

			<!-- 富文本内容 -->
			<view class="content-wrapper">
				<view class="rich-text-container">
					<rich-text class="rich-text" :nodes="hotelDetail.intro"></rich-text>
				</view>
			</view>


			<!-- <view class="section">
				<view class="section-header">
					<svg-icon name="info" size="32" />
					<text class="section-title">酒店信息</text>
				</view>
				<view class="info-card">
					<view class="info-item">
						<svg-icon name="location" size="16" class="info-icon" />
						<view class="info-content">
							<view class="info-label">酒店位置</view>
							<view class="info-value">{{ hotelDetail.location }}</view>
						</view>
					</view>
					<view class="info-item">
						<text class="info-icon">🕐</text>
						<view class="info-content">
							<view class="info-label">营业时间</view>
							<view class="info-value">{{ hotelDetail.businessHours }}</view>
						</view>
					</view>
					<view class="info-item">
						<svg-icon name="phone" size="16" class="info-icon" />
						<view class="info-content">
							<view class="info-label">联系电话</view>
							<view class="info-value">{{ hotelDetail.phone }}</view>
						</view>
					</view>
					<view class="info-item">
						<svg-icon name="star" size="16" class="info-icon" />
						<view class="info-content">
							<view class="info-label">酒店等级</view>
							<view class="info-value">{{ hotelDetail.level }}</view>
						</view>
					</view>
				</view>
			</view>

			<view class="section">
				<view class="section-header">
					<svg-icon name="lightbulb" size="32" />
					<text class="section-title">酒店特色</text>
				</view>
				<view class="features-list">
					<view class="feature-item" v-for="(feature, index) in hotelDetail.features" :key="index">
						<view class="feature-icon">{{ feature.icon }}</view>
						<view class="feature-content">
							<view class="feature-name">{{ feature.name }}</view>
							<view class="feature-desc">{{ feature.description }}</view>
						</view>
					</view>
				</view>
			</view> -->

			<!-- 温馨提示 -->
			<view class="section">
				<view class="section-header">
					<svg-icon name="lightbulb" size="32" />
					<text class="section-title">温馨提示</text>
				</view>
				<view class="tips-card">
					<view class="tip-item" v-for="(tip, index) in commonTips" :key="index">
						<text class="tip-bullet">•</text>
						<text class="tip-text">{{ tip }}</text>
					</view>
				</view>
			</view>

			<!-- 底部占位 -->
			<view class="bottom-placeholder"></view>
		</scroll-view>
	</view>
</template>

<script setup>
import { ref, reactive, onMounted, watch, computed, nextTick, toRefs } from 'vue';
import { onLoad, onShow, onShareAppMessage } from '@dcloudio/uni-app';
import common from '@/utils/common.js';
import api from '@/api/index.js';

import useUserInfoStore from '@/stores/user';
import { storeToRefs } from 'pinia';

const userInfoStore = useUserInfoStore();
const { userData } = toRefs(userInfoStore);

const imgUrl = uni.imgUrl;

// 酒店详情数据
const hotelDetail = ref({});

// 通用提示
const commonTips = ref([
	'请提前致电预订，确保有房',
	'入住时请携带有效身份证件',
	'酒店提供免费WiFi服务',
	'如需接送服务，请提前联系酒店',
	'退房时间为中午12:00，如需延迟退房请提前申请',
	'酒店内禁止吸烟，设有专门的吸烟区'
]);

onLoad((options) => {
	if (options.id) {
		getData(options.id);
	}
});

onMounted(() => { });

// 导航到推荐地点
const navigateToLocation = () => {
	if (hotelDetail.value.position) {
		common.openMapNavigation(hotelDetail.value.position.latitude, hotelDetail.value.position.longitude, hotelDetail.value.position.name);
	}
};

const getData = (id) => {
	api.attractionsApi.detailSpot({ id }).then((res) => {
		console.log('酒店详情', res);
		hotelDetail.value = res
	}).catch((error) => {
		console.error('获取酒店详情失败:', error);
	});
};

</script>

<style lang="scss" scoped>
.container {
	background: linear-gradient(180deg, #87CEEB 0%, #F0F8FF 50%, #ffffff 100%);
	height: 100vh;
	width: 100%;
	position: relative;
	overflow: hidden;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}

.content {
	flex: 1;
	overflow: hidden;
	box-sizing: border-box;
	position: relative;
	z-index: 1;
}

/* 图片区域 */
.image-section {
	position: relative;
	height: 500rpx;
	margin: 0 30rpx 30rpx 30rpx;
	border-radius: 20rpx;
	overflow: hidden;

	.main-image {
		width: 100%;
		height: 100%;
	}

	.image-overlay {
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
		padding: 40rpx 30rpx 30rpx;
		color: white;
		display: flex;
		justify-content: space-between;
		align-items: flex-end;

		.hotel-btn {

			.navigate-btn {
				background: linear-gradient(135deg, #4CAF50, #66BB6A);
				color: white;
				border: none;
				border-radius: 30rpx;
				padding: 0rpx 30rpx;
				font-size: 24rpx;
				font-weight: bold;
				box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.3);

				&::after {
					border: none;
				}

				&:active {
					transform: scale(0.95);
				}
			}
		}

		.hotel-name {
			font-size: 36rpx;
			font-weight: bold;
			margin-bottom: 10rpx;
		}

		.hotel-subtitle {
			font-size: 26rpx;
			opacity: 0.9;
		}
	}
}

.section {
	margin: 0 30rpx 40rpx 30rpx;

	.section-header {
		display: flex;
		align-items: center;
		gap: 15rpx;
		padding: 20rpx 0;
		border-bottom: 1rpx solid #eee;
		margin-bottom: 20rpx;

		.section-title {
			font-size: 32rpx;
			font-weight: bold;
			color: #2E7D32;
		}
	}
}

/* 描述卡片 */
.description-card {
	background: rgba(255, 255, 255, 0.95);
	border-radius: 20rpx;
	padding: 30rpx;
	box-shadow: 0 4rpx 20rpx rgba(135, 206, 235, 0.1);

	.description-text {
		font-size: 28rpx;
		line-height: 1.6;
		color: #333;
	}
}

/* 信息卡片 */
.info-card {
	background: rgba(255, 255, 255, 0.95);
	border-radius: 20rpx;
	padding: 30rpx;
	box-shadow: 0 4rpx 20rpx rgba(135, 206, 235, 0.1);

	.info-item {
		display: flex;
		align-items: flex-start;
		margin-bottom: 25rpx;
		gap: 20rpx;

		&:last-child {
			margin-bottom: 0;
		}

		.info-icon {
			font-size: 24rpx;
			margin-top: 4rpx;
			flex-shrink: 0;
		}

		.info-content {
			flex: 1;

			.info-label {
				font-size: 24rpx;
				color: #666;
				margin-bottom: 5rpx;
			}

			.info-value {
				font-size: 26rpx;
				color: #333;
				font-weight: 500;
			}
		}
	}
}

/* 特色列表 */
.features-list {
	background: rgba(255, 255, 255, 0.95);
	border-radius: 20rpx;
	padding: 30rpx;
	box-shadow: 0 4rpx 20rpx rgba(135, 206, 235, 0.1);

	.feature-item {
		display: flex;
		align-items: flex-start;
		margin-bottom: 30rpx;
		gap: 20rpx;

		&:last-child {
			margin-bottom: 0;
		}

		.feature-icon {
			font-size: 36rpx;
			margin-top: 5rpx;
			flex-shrink: 0;
		}

		.feature-content {
			flex: 1;

			.feature-name {
				font-size: 28rpx;
				font-weight: bold;
				color: #2E7D32;
				margin-bottom: 8rpx;
			}

			.feature-desc {
				font-size: 24rpx;
				color: #666;
				line-height: 1.5;
			}
		}
	}
}

/* 提示卡片 */
.tips-card {
	background: rgba(255, 255, 255, 0.95);
	border-radius: 20rpx;
	padding: 30rpx;
	box-shadow: 0 4rpx 20rpx rgba(135, 206, 235, 0.1);

	.tip-item {
		display: flex;
		align-items: flex-start;
		margin-bottom: 15rpx;
		gap: 15rpx;

		&:last-child {
			margin-bottom: 0;
		}

		.tip-bullet {
			color: #4CAF50;
			font-weight: bold;
			font-size: 28rpx;
			flex-shrink: 0;
			margin-top: 2rpx;
		}

		.tip-text {
			font-size: 26rpx;
			color: #333;
			line-height: 1.5;
			flex: 1;
		}
	}
}


.content-wrapper {
	margin-top: 20rpx;
	padding: 40rpx;
	box-sizing: border-box;

	.rich-text-container {
		.rich-text {
			line-height: 1.8;
			color: #333;
			font-size: 28rpx;
		}
	}
}

.bottom-placeholder {
	height: 100rpx;
}
</style>